using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Firestarter.DB.Schema.BO;
using Firestarter.DB.Schema.Test.Logic;
using FireStarterModeller.BO;
using Firestarter.DB.Schema.UI;
using Habanero.BO;
using Habanero.Faces.Base;
using Habanero.Faces.Win;
using Habanero.Testability;
using NUnit.Framework;

namespace Firestarter.DB.Schema.Test.UI
{
    
    [TestFixture]
    public class TestModelModificationsControl:TestBase
    {
        [Test]
        public void Test_ControlSetup()
        {
            //---------------Set up test pack-------------------
            //-------------Assert Preconditions -------------

            //---------------Execute Test ----------------------
            ModelModificationsControl modelModificationsControl = new ModelModificationsControl();
            //---------------Test Result -----------------------
            Assert.IsFalse(modelModificationsControl.EditableGridControl.Buttons.Visible);
            Assert.IsFalse(modelModificationsControl.EditableGridControl.FilterControl.Visible);
        }
        [Test]
        public void Test_ModelModifications_Empty()
        {
            //---------------Set up test pack-------------------
            ModelModificationsControl modelModificationsControl = new ModelModificationsControl();
            BusinessObjectCollection<ModelModification> modelModifications = new BusinessObjectCollection<ModelModification>();
            //-------------Assert Preconditions -------------

            //---------------Execute Test ----------------------
            modelModificationsControl.ModelModifications = modelModifications;
            //---------------Test Result -----------------------
            Assert.AreSame(modelModifications, modelModificationsControl.ModelModifications);
            Assert.AreEqual(1, modelModificationsControl.EditableGridControl.Grid.RowCount);
        }
        [Test]
        public void Test_ModelModifications_TwoRows()
        {
            //---------------Set up test pack-------------------
            ModelModificationsControl modelModificationsControl = new ModelModificationsControl();
            BusinessObjectCollection<ModelModification> modelModifications = new BusinessObjectCollection<ModelModification>();
            modelModifications.Add(new ModelModification { Description = GetRandomString() });
            modelModifications.Add(new ModelModification { Description = GetRandomString() });
            //-------------Assert Preconditions -------------

            //---------------Execute Test ----------------------
            modelModificationsControl.ModelModifications = modelModifications;
            //---------------Test Result -----------------------
            Assert.AreSame(modelModifications, modelModificationsControl.ModelModifications);
            Assert.AreEqual(3, modelModificationsControl.EditableGridControl.Grid.RowCount);
        }
        
        private static string GetRandomString()
        {
            return RandomValueGen.GetRandomString();
        }
    }
}
